package com.test

import com.entity.PackPath
import com.subpackage.CompressJS
import kotlin.system.exitProcess
import kotlin.test.Test

class JSTest {


    @Test
    fun test() {

        val oldJs = PackPath("E:\\WorkSpace\\LayaBox\\TypeScriptLib\\dist\\gameCore.js")
        val minJs = PackPath("E:\\WorkSpace\\LayaBox\\TypeScriptLib\\dist2\\gameCore.js")

        // System.out.println(oldJs.getPath());
        // System.out.println(minJs.getPath());
// BUNDLE, WHITESPACE_ONLY, SIMPLE (default), ADVANCED\
//        LanguageMode.ECMASCRIPT_2016.name
        val values = arrayOf(
            "--js", oldJs.pathString,
            "--js_output_file", minJs.pathString,
            "--language_in", "ECMASCRIPT_2016",
            "--language_out", "ECMASCRIPT_2016",
//            "--debug", "true",
//            "--externs", "E:\\WorkSpace\\LayaBox\\TypeScriptLib\\template\\laya.core.min.js,E:\\WorkSpace\\LayaBox\\TypeScriptLib\\template\\fairygui.min.js",
//            "--compilation_level", "SIMPLE"
        )
        val compressJS = CompressJS(values)
        compressJS.setExitCodeReceiver {
            if (compressJS.hasErrors()) exitProcess(-1)
            null
        }
        if (compressJS.shouldRunCompiler()) {
            compressJS.run()
            // if (Config.unpackScene > 1) {
            // oldJs.delete();
            // }
        } else {
            println("配置错误!")
        }

//        JSUtils.load("E:\\WorkSpace\\Idea\\TypeScript\\KickersX\\html-template\\index.js")


    }


}